package com.xpec.c4.db.hibernate.manager;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.cfg.Configuration;

import com.ms.business.db.BusinessCooperatorRequestLogModel;
import com.ms.game.bank.db.BankLogModel;
import com.ms.game.bank.db.CashLogModel;
import com.ms.game.bank.db.VipLogModel;
import com.ms.game.billing.GameBillingModel;
import com.ms.game.billing.GameBillingRestrictedListModel;
import com.ms.game.billing.StoreLimitModel;
import com.ms.game.characterInfo.db.CharacterTodayInfoLog;
import com.ms.game.forciblyBulletin.db.ForciblyBulletinModel;
import com.ms.game.gameActivity.db.GameActivitySettingModel;
import com.ms.game.invitefriend.db.DistributorInviteCodesModel;
import com.ms.game.invitefriend.db.DistributorsModel;
import com.ms.game.invitefriend.db.InviteCodeGroupModel;
import com.ms.game.invitefriend.db.InviteCodeModel;
import com.ms.game.invitefriend.db.InviteCodeUseRecordModel;
import com.ms.game.invitefriend.db.InviteFriendComLogModel;
import com.ms.game.invitefriend.db.InviteFriendComSumLogModel;
import com.ms.game.invitefriend.db.PreparedDistributorInviteCodeModel;
import com.ms.game.invitefriend.db.PreparedInviteCodeModel;
import com.ms.game.invitefriend.db.SubDistribuorModifyLogModel;
import com.ms.game.invitefriend.db.SubDistributorsModel;
import com.ms.game.itembox.db.AccountItemChangeLogModel;
import com.ms.game.itembox.db.AccountItemModel;
import com.ms.game.itembox.db.ChangeNameLogModel;
import com.ms.game.itembox.db.ItemBoxModel;
import com.ms.game.itembox.db.PlayerCrystalChangeLogModel;
import com.ms.game.itembox.db.PlayerItemChangeLogModel;
import com.ms.game.itembox.db.PlayerItemModel;
import com.ms.game.itembox.db.PlayerItemRefineLogModel;
import com.ms.game.itembox.db.RollItemInGameLogModel;
import com.ms.game.itembox.db.TreasureBoxChangeLogModel;
import com.ms.game.level.db.LevelLogModel;
import com.ms.game.lobby.db.BulletinModel;
import com.ms.game.lobby.db.GameLobbyJackpotNotifyLogModel;
import com.ms.game.lobby.db.LobbyGameListWhileModel;
import com.ms.game.lobby.terminatedaccountlist.db.TerminatedAccountListModel;
import com.ms.game.password.db.PasswordLogModel;
import com.ms.game.rebate.db.ClearRebateLogModel;
import com.ms.game.rebate.db.RebateLogModel;
import com.ms.game.rebate.db.RebateModel;
import com.ms.game.sendgift.db.SendGiftNotifyModel;
import com.ms.game.sendgift.db.SendGiftRecordLog;
import com.ms.service.gmtool.log.PlayerLoginLogModel;
import com.ms.service.module.account.accountloginblocker.db.AccountLoginIPBlockLogModel;
import com.ms.service.module.account.db.AccountModel;
import com.ms.service.module.account.db.TcpProxyServerGroupListModel;
import com.ms.service.module.analysis.db.model.ClientReportModel;
import com.ms.service.module.analysis.db.model.PlayerEnterSeatLogModel;
import com.ms.service.module.analysis.db.model.RealTimeAnalysisModel;
import com.ms.service.module.analysis.db.model.RealTimeAnalysisModelV2;
import com.ms.service.module.analysisgroup.db.model.CoinExpenditureAlertSettingModel;
import com.ms.service.module.analysisgroup.db.model.CoinExpenditureLogModel;
import com.ms.service.module.analysisgroup.db.model.GameOperateAlertLogModel;
import com.ms.service.module.analysisgroup.db.model.GameRevenueAndExpenditureAlertLogModel;
import com.ms.service.module.analysisgroup.db.model.GameRevenueAndExpenditureModel;
import com.ms.service.module.analysisgroup.db.model.GameUseItemLogModel;
import com.ms.service.module.analysisgroup.db.model.ItemChangeCountModel;
import com.ms.service.module.analysisgroup.db.model.UsedCoinCardDetailLogModel;
import com.ms.service.module.baccarat.db.BacrActivityCombosInfoModel;
import com.ms.service.module.baccarat.db.BacrActivityCombosLogModel;
import com.ms.service.module.baccarat.db.BacrGameLogModel;
import com.ms.service.module.baccarat.db.BacrMachineDataModel;
import com.ms.service.module.baccarat.db.BacrPlayerLogModel;
import com.ms.service.module.commonsettings.CommonSettingsModel;
import com.ms.service.module.fish.db.FishPlayerLogModel;
import com.ms.service.module.logspout.db.LogSpoutModel;
import com.ms.service.module.zone.db.DebugCommandLogModel;
import com.ms.service.module.zone.db.GameHallConfigModel;
import com.ms.service.module.zone.db.GameJackPotDataModel;
import com.ms.service.module.zone.db.GameJackPotLogModel;
import com.ms.service.module.zone.db.GameJackPotTranscationLog;
import com.xpec.c4.db.model.CooperatorAccountModel;
import com.xpec.c4.db.model.PlayerKeepSeatClearLogModel;
import com.xpec.c4.db.model.PlayerKeepSeatLogModel;
import com.xpec.c4.db.model.PlayerKeepSeatModel;
import com.xpec.c4.db.model.PlayerModel;
import com.xpec.c4.db.model.basic.BasicGameModel;
import com.xpec.c4.db.model.basic.BasicModel;
import com.xpec.c4.db.model.basic.GameSealUpModel;
import com.xpec.c4.db.model.global.DBIpFilterModel;
import com.xpec.c4.db.model.log.DBAccountLoginLog;
import com.xpec.c4.db.model.log.DBCharacterActionLog;
import com.xpec.c4.db.model.log.PlayerNumLogModel;
import com.xpec.c4.game.spinMoneyRecorder.db.SpinMoneyRecordLogModel;
import com.xpec.c4.game.utility.wordfilter.db.PlayerNameFilterModel;
import com.xpec.c4.service.module.ServerProperties;
import com.xpec.c4.service.module.datacenter.player.db.DailyExchangeLogModel;
import com.xpec.c4.service.module.datacenter.player.db.OpenScoreLogModel;
import com.xpec.c4.service.module.datacenter.player.db.PlayerMoneyChangeLogModel;
import com.xpec.c4.service.module.datacenter.player.db.PlayerTmpCashChangeLogModel;
import com.xpec.c4.service.utility.encrypt.EncryptBase;
import com.xpec.c4.service.utility.encrypt.EncryptXAES;
import com.xpec.c4.service.utility.encrypt.XData;
import com.xpec.c4.service.utility.encrypt.XKey;

/**
 * 数据库映射管理类
 * 
 * @author guoqi
 * 
 */
public class ConfigurationManager {

	/**
	 * 
	 */
	private static final Log log = LogFactory.getLog(ConfigurationManager.class);

	/**
	 * 
	 */
	private static HashMap<ManagerType, Set<Class<? extends BasicModel>>> modelMapSets = new HashMap<ManagerType, Set<Class<? extends BasicModel>>>();

	/**
	 * 
	 */
	private static HashMap<ManagerType, Configuration> configs = new HashMap<ManagerType, Configuration>();

	/**
	 * 
	 */
	private static boolean autoCreateTables = false;

	/**
	 * 
	 */
	private static boolean inited = false;

	/**
	 * 
	 */
	private static String KEY_STRING = "xpec";

	/**
	 * 循環資料表 -記錄 class 對應 資料表名稱
	 */
	private static HashMap<String, String> recyleModel = new HashMap<String, String>();

	/**
	 * 循環資料表 - 對應資料表名稱
	 * 
	 * @param classname
	 * @return
	 */
	public static String getRecyleTableName(String classname) {
		if (recyleModel.containsKey(classname)) {
			return recyleModel.get(classname);
		}

		return null;
	}

	public static boolean isAutoCreateTables() {
		return autoCreateTables;
	}

	public static void setAutoCreateTables(boolean autoCreateTables) {
		ConfigurationManager.autoCreateTables = autoCreateTables;
	}

	private static void init() {
		// 初始化ManagerType
		for (ManagerType type : ManagerType.values()) {
			modelMapSets.put(type, new HashSet<Class<? extends BasicModel>>());
		}

		// 初始化mapping
		initGameModelMap();
		initLogModelMap();
		initBusinessModelMap();
		initAnalysisModelMap();

		inited = true;
	}

	/**
	 * 获得canaan的类表配置 配置文件默认为HIBERNATE_CFG_XML_FILE_PATH
	 * 
	 * @return
	 */
	public static synchronized Configuration getHibernateConfiguration(ManagerType type) {
		if (!inited) {
			init();
		}
		// return
		// getHibernateConfiguration(filePath+HIBERNATE_CFG_XML_FILE_NAME,type);
		Configuration config = configs.get(type);
		if (config == null) {
			config = initConfiguration(type);
			configs.put(type, config);
		}
		return config;
	}

	/**
	 * 
	 * @param property
	 * @return
	 */
	private static String transPassword(String property) {
		// 優先讀取加密過的密碼字串, 如果讀得出來的話進行解碼
		String spass = ServerProperties.getProperty(property);

		spass = decryptText(spass);

		return spass;
	}

	/**
	 * 解密「加密字串」
	 * 
	 * @param encryptText
	 *            被加密的字串
	 * @return 解密後的字串
	 */
	public static String decryptText(String encryptText) {
		try {
			if (encryptText != null && encryptText.length() > 0) {
				EncryptBase encrypt = new EncryptXAES();
				XKey key = new XKey(KEY_STRING);
				Base64 base64 = new Base64();
				// 轉回原本加密的數據
				byte tmp[] = base64.decode(encryptText.getBytes());

				// 對buff解密
				XData data2 = new XData();
				data2.setEncodeData(tmp);
				encrypt.decode(data2, key);
				// 再轉成可讀的string
				encryptText = new String(data2.getOriginData());
			}
		} catch (Exception e) {
			log.error(e, e);
		}

		return encryptText;
	}

	/**
	 * 
	 * @param type
	 * @return
	 */
	public static Configuration initConfiguration(ManagerType type) {

		Configuration configuration = new Configuration();
		if (type == ManagerType.MOBILE) {
			configuration.configure("/hibernate_mobile.cfg.xml");
		} else {
			configuration.configure();
		}

		if (autoCreateTables) {
			configuration.setProperty("hibernate.hbm2ddl.auto", "update");
		} else {
			configuration.setProperty("hibernate.hbm2ddl.auto", "none");
		}

		String spass = null;

		switch (type) {

		case GLOBAL:

			configuration.setProperty("connection.url", ServerProperties.getProperty("db_global_url"));
			configuration.setProperty("hibernate.connection.url", ServerProperties.getProperty("db_global_url"));

			configuration.setProperty("connection.username", ServerProperties.getProperty("db_global_username"));
			configuration.setProperty("hibernate.connection.username",
					ServerProperties.getProperty("db_global_username"));

			spass = transPassword("db_global_spassword");
			if (spass == null) {
				spass = ServerProperties.getProperty("db_global_password");
			}
			configuration.setProperty("connection.password", spass);
			configuration.setProperty("hibernate.connection.password", spass);

			break;

		case GAME:
			configuration.setProperty("connection.url", ServerProperties.getProperty("db_game_url"));
			configuration.setProperty("hibernate.connection.url", ServerProperties.getProperty("db_game_url"));

			configuration.setProperty("connection.username", ServerProperties.getProperty("db_game_username"));
			configuration.setProperty("hibernate.connection.username",
					ServerProperties.getProperty("db_game_username"));

			// 優先讀取加密過的密碼字串
			spass = transPassword("db_game_spassword");
			if (spass == null) {
				spass = ServerProperties.getProperty("db_game_password");
			}
			configuration.setProperty("connection.password", spass);
			configuration.setProperty("hibernate.connection.password", spass);

			break;

		case BUSINESS:
			configuration.setProperty("connection.url", ServerProperties.getProperty("db_business_url"));
			configuration.setProperty("hibernate.connection.url", ServerProperties.getProperty("db_business_url"));

			configuration.setProperty("connection.username", ServerProperties.getProperty("db_business_username"));
			configuration.setProperty("hibernate.connection.username",
					ServerProperties.getProperty("db_business_username"));

			// 優先讀取加密過的密碼字串
			spass = transPassword("db_business_spassword");
			if (spass == null) {
				spass = ServerProperties.getProperty("db_business_password");
			}

			configuration.setProperty("connection.password", spass);
			configuration.setProperty("hibernate.connection.password", spass);

			break;

		case LOG:
			configuration.setProperty("connection.url", ServerProperties.getProperty("db_log_url"));
			configuration.setProperty("hibernate.connection.url", ServerProperties.getProperty("db_log_url"));

			configuration.setProperty("connection.username", ServerProperties.getProperty("db_log_username"));
			configuration.setProperty("hibernate.connection.username",
					ServerProperties.getProperty("db_log_username"));

			// 優先讀取加密過的密碼字串
			spass = transPassword("db_log_spassword");
			if (spass == null) {
				spass = ServerProperties.getProperty("db_log_password");
			}
			configuration.setProperty("connection.password", spass);
			configuration.setProperty("hibernate.connection.password", spass);

			break;

		case MOBILE:
			configuration.setProperty("connection.url", ServerProperties.getProperty("db_mobile_url"));
			configuration.setProperty("hibernate.connection.url", ServerProperties.getProperty("db_mobile_url"));

			configuration.setProperty("connection.username", ServerProperties.getProperty("db_mobile_username"));
			configuration.setProperty("hibernate.connection.username",
					ServerProperties.getProperty("db_mobile_username"));

			// 優先讀取加密過的密碼字串
			spass = transPassword("db_mobile_spassword");
			if (spass == null) {
				spass = ServerProperties.getProperty("db_mobile_password");
			}

			configuration.setProperty("connection.password", spass);
			configuration.setProperty("hibernate.connection.password", spass);
			break;

		case ANALYSIS:
			configuration.setProperty("connection.url", ServerProperties.getProperty("db_analysis_url"));
			configuration.setProperty("hibernate.connection.url", ServerProperties.getProperty("db_analysis_url"));

			configuration.setProperty("connection.username", ServerProperties.getProperty("db_analysis_username"));
			configuration.setProperty("hibernate.connection.username",
					ServerProperties.getProperty("db_analysis_username"));

			// 優先讀取加密過的密碼字串
			spass = transPassword("db_analysis_spassword");
			if (spass == null) {
				spass = ServerProperties.getProperty("db_analysis_password");
			}

			configuration.setProperty("connection.password", spass);
			configuration.setProperty("hibernate.connection.password", spass);
			break;
		}

		// 添加映射类
		Set<Class<? extends BasicModel>> clazzs = modelMapSets.get(type);
		for (Class<? extends BasicModel> clazz : clazzs) {
			if (clazz != null) {
				configuration.addAnnotatedClass(clazz);
			}
		}

		return configuration;
	}

	/**
	 * 获得URL地址
	 * 
	 * @param type
	 * @return
	 *
	 * @2011-8-30 下午05:09:30
	 */
	public static String getConnectionUrl(ManagerType type) {

		switch (type) {
		case GAME:
			return ServerProperties.getProperty("db_game_url");
		case BUSINESS:
			return ServerProperties.getProperty("db_business_url");
		case LOG:
			return ServerProperties.getProperty("db_log_url");
		case GLOBAL:
			return ServerProperties.getProperty("db_global_url");
		case ANALYSIS:
			return ServerProperties.getProperty("db_analysis_url");
		default:
			return null;
		}
	}

	/**
	 * Hibernate中增加一个新的model
	 * 
	 * @param clazz
	 */
	public static void addHibernate(ManagerType type, Class<? extends BasicGameModel> clazz) {
		Set<Class<? extends BasicModel>> mapSets = modelMapSets.get(type);
		if (mapSets == null) {
			mapSets = new HashSet<Class<? extends BasicModel>>();
			modelMapSets.put(type, mapSets);
		}
		mapSets.add(clazz);
	}

	/**
	 * 初始化canaan库的映射MODEL
	 */
	private static void initGameModelMap() {
		Set<Class<? extends BasicModel>> mapSets = modelMapSets.get(ManagerType.GAME);
		mapSets.add(PlayerModel.class);

		mapSets.add(AccountModel.class);
		mapSets.add(CooperatorAccountModel.class);
		mapSets.add(TcpProxyServerGroupListModel.class);

		// 道具設定資料
		mapSets.add(ItemBoxModel.class);

		/** 回饋金 */
		mapSets.add(RebateModel.class);

		/** 大廳 **/
		mapSets.add(GameHallConfigModel.class);

		/** GAME JP **/
		mapSets.add(GameJackPotDataModel.class);

		/** 寄送禮物 **/
		mapSets.add(SendGiftNotifyModel.class);

		/** player **/
		mapSets.add(PlayerKeepSeatModel.class);

		/** 聊天室 **/
		mapSets.add(InviteCodeGroupModel.class);

		/** 公告 **/
		mapSets.add(BulletinModel.class);

		/** 強制公告 **/
		mapSets.add(ForciblyBulletinModel.class);
		/** 道具 */
		mapSets.add(PlayerItemModel.class);

		/** 共用背包(帳號背包) */
		mapSets.add(AccountItemModel.class);

		/** 邀請碼 */
		mapSets.add(InviteCodeModel.class);

		/** 經銷商 **/
		mapSets.add(DistributorsModel.class);

		/** 子經銷商 **/
		mapSets.add(SubDistributorsModel.class);

		/** 經銷商邀請碼 **/
		mapSets.add(DistributorInviteCodesModel.class);

		/** 預先產好的邀請碼 */
		mapSets.add(PreparedInviteCodeModel.class);

		/** 預先產好的經銷商邀請碼 */
		mapSets.add(PreparedDistributorInviteCodeModel.class);

		/** IAP儲值驗證 */
		mapSets.add(GameBillingModel.class);

		/** iap 儲值限制 */
		mapSets.add(StoreLimitModel.class);

		/** 額外設定的儲值限制 */
		mapSets.add(GameBillingRestrictedListModel.class);

		/** 由 db 設定的創角關鍵字列表 **/
		mapSets.add(PlayerNameFilterModel.class);

		/** 共用設定 */
		mapSets.add(CommonSettingsModel.class);

		/** 活動設定 */
		mapSets.add(GameActivitySettingModel.class);

		/** 停權名單 */
		mapSets.add(TerminatedAccountListModel.class);
		
		/**百家樂**/
		mapSets.add(BacrMachineDataModel.class);
		mapSets.add(BacrActivityCombosInfoModel.class);
	}

	/**
	 * 初始化全域使用的資料庫
	 */
	private static void initGlobalModelMap() {
		Set<Class<? extends BasicModel>> mapSets = modelMapSets.get(ManagerType.GLOBAL);
		mapSets.add(com.xpec.c4.db.model.global.DBIpFilterModel.class);
	}

	/**
	 * 初始化gmdb库的映射MODEL
	 */
	private static void initLogModelMap() {
		Set<Class<? extends BasicModel>> mapSets = modelMapSets.get(ManagerType.LOG);
		mapSets.add(DBIpFilterModel.class);

		mapSets.add(DBCharacterActionLog.class);
		mapSets.add(GameLobbyJackpotNotifyLogModel.class);
		mapSets.add(CharacterTodayInfoLog.class);

		mapSets.add(PlayerItemChangeLogModel.class);
		mapSets.add(AccountItemChangeLogModel.class);

		// 邀請好友抽佣
		mapSets.add(InviteFriendComLogModel.class);
		mapSets.add(InviteFriendComSumLogModel.class);
		/** 子經銷商的抽傭修改紀錄 **/
		mapSets.add(SubDistribuorModifyLogModel.class);

		// 邀請碼
		mapSets.add(InviteCodeUseRecordModel.class);

		/** 銀行 */
		mapSets.add(BankLogModel.class);
		/** 回饋金 */
		mapSets.add(ClearRebateLogModel.class);
		mapSets.add(RebateLogModel.class);

		/** 點數 */
		mapSets.add(CashLogModel.class);
		/** vip */
		mapSets.add(VipLogModel.class);
		/** 等級 */
		mapSets.add(LevelLogModel.class);
		/** 密碼錯誤 */
		mapSets.add(PasswordLogModel.class);

		/** 寄送禮物log **/
		mapSets.add(SendGiftRecordLog.class);

		/** 玩家資訊 保留座位記錄 **/
		mapSets.add(PlayerKeepSeatLogModel.class);
		mapSets.add(PlayerKeepSeatClearLogModel.class);

		/** game jackpot **/
		mapSets.add(GameJackPotLogModel.class);
		mapSets.add(GameJackPotTranscationLog.class);

		/** 密技 command */
		mapSets.add(DebugCommandLogModel.class);

		/** 道具精煉 */
		mapSets.add(PlayerItemRefineLogModel.class);
		mapSets.add(PlayerCrystalChangeLogModel.class);

		/** 線上人數 */
		mapSets.add(PlayerNumLogModel.class);

		/** 機台出入紀錄 **/
		mapSets.add(PlayerEnterSeatLogModel.class);

		/** spin n 次後記錄玩家金錢記錄 */
		mapSets.add(SpinMoneyRecordLogModel.class);

		/** 使用道具卡進行遊戲紀錄 */
		mapSets.add(GameUseItemLogModel.class);

		/** 改名字記錄 */
		mapSets.add(ChangeNameLogModel.class);

		/** 遊戲中掉落物品紀錄 */
		mapSets.add(RollItemInGameLogModel.class);

		/** 升級寶箱兌換紀錄 */
		mapSets.add(TreasureBoxChangeLogModel.class);

		/** 遊戲封存記錄表 */
		mapSets.add(GameSealUpModel.class);

		/** 帳號登入紀錄 */
		mapSets.add(DBAccountLoginLog.class);
		
		/**百家樂**/
		mapSets.add(BacrActivityCombosLogModel.class);
		
		/**百家樂**/
		mapSets.add(BacrGameLogModel.class);
		mapSets.add(BacrPlayerLogModel.class);
		mapSets.add(BacrActivityCombosLogModel.class);

		/**捕鱼**/
		mapSets.add(FishPlayerLogModel.class);
		
		
		// 循環性log
		recyleLogModelMap();
	}

	/**
	 * 循環性log model
	 */
	private static void recyleLogModelMap() {
		HashSet<Class<? extends BasicModel>> mapSets = new HashSet<Class<? extends BasicModel>>();

		/** 玩家資產記錄 **/
		mapSets.add(PlayerMoneyChangeLogModel.class);
		mapSets.add(PlayerTmpCashChangeLogModel.class);
		mapSets.add(OpenScoreLogModel.class);
		mapSets.add(DailyExchangeLogModel.class);

		/** 角色登入紀錄 **/
		mapSets.add(PlayerLoginLogModel.class);

		/** ip阻擋紀錄 */
		mapSets.add(AccountLoginIPBlockLogModel.class);

		/** logspout */
		mapSets.add(LogSpoutModel.class);

		/** 加入log model中 **/
		setRecyleLogModel(mapSets);

		HashSet<Class<? extends BasicModel>> map = (HashSet<Class<? extends BasicModel>>) modelMapSets
				.get(ManagerType.LOG);
		map.addAll(mapSets);
	}

	/**
	 * 記錄循環log model資料
	 */
	private static void setRecyleLogModel(Set<Class<? extends BasicModel>> mapSets) {
		Iterator<Class<? extends BasicModel>> iter = mapSets.iterator();

		while (iter.hasNext()) {
			Class<? extends BasicModel> c = iter.next();
			Annotation annotation = c.getAnnotation(javax.persistence.Table.class);
			try {
				Class<? extends Annotation> type = annotation.annotationType();
				for (Method method : type.getDeclaredMethods()) {
					if (method.getName().equals("name")) {
						Object value = method.invoke(annotation, (Object[]) null);
						if (!recyleModel.containsKey(method.getName())) {
							recyleModel.put(c.getSimpleName(), (String) value);
						}
					}
				}

			} catch (SecurityException | IllegalAccessException | IllegalArgumentException
					| InvocationTargetException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}

	/**
	 * 初始化business库的映射MODEL
	 */
	private static void initBusinessModelMap() {
		Set<Class<? extends BasicModel>> mapSets = modelMapSets.get(ManagerType.BUSINESS);
		mapSets.add(BusinessCooperatorRequestLogModel.class);
		mapSets.add(LobbyGameListWhileModel.class);
	}

	/**
	 * 初始化analysis库的映射MODEL
	 */
	private static void initAnalysisModelMap() {
		Set<Class<? extends BasicModel>> mapSets = modelMapSets.get(ManagerType.ANALYSIS);

		/** 即時遊戲人數&投注額紀錄 **/
		mapSets.add(RealTimeAnalysisModel.class);

		/** 客戶端回報紀錄 **/
		mapSets.add(ClientReportModel.class);

		/** 遊戲館收支紀錄 **/
		mapSets.add(GameRevenueAndExpenditureModel.class);

		/** 收支警示紀錄 **/
		mapSets.add(GameRevenueAndExpenditureAlertLogModel.class);

		/** C幣產出紀錄 */
		mapSets.add(CoinExpenditureLogModel.class);

		/** C幣產出警示設定 */
		mapSets.add(CoinExpenditureAlertSettingModel.class);

		/** 遊戲操作警示紀錄 */
		mapSets.add(GameOperateAlertLogModel.class);

		/** 物品變化紀錄 */
		mapSets.add(ItemChangeCountModel.class);

		/** C幣卡使用細節紀錄 */
		mapSets.add(UsedCoinCardDetailLogModel.class);

		/** 新版統計(分幣值) */
		mapSets.add(RealTimeAnalysisModelV2.class);
	}

	public static void resetConfigs() {
		configs.clear();
		modelMapSets.clear();
		inited = false;
	}

	public static HashMap<String, String> getRecyleModel() {
		return recyleModel;
	}
}
